package com.kele.springcloud.service.impl;

import com.kele.springcloud.pojo.Dept;
import com.kele.springcloud.service.DeptClientService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description:
 * @Author: Kele
 * @CreateDate: 2021/7/13 9:28
 * @Version:
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long id) {
                return new Dept()
                        .setDept_no(id)
                        .setDept_name("id=>" + id + "没有对应的信息，客户端提供了降级的功能，这个服务已经关闭了")
                        .setDb_source("没有数据");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
